//index.js
//获取应用实例
import Request from '../../JavaScript/request'
import Comfn from '../../JavaScript/common'

let IndexApi = Request.Index


Page({
  data: {
    indexTable:[],
    dialog:false
  },
  onActiveUrl(){
    wx.navigateTo({
      url: '../select/select',
      })
  },
  onUpload() {
    
  },

  onLogin() {
    
  },
  onShow: function(option) {
    let self = this;
    wx.getSetting({
      success: res => {
        if (!res.authSetting['scope.userInfo']) {
          this.setData({
            dialog: true
          })
        } else {
          wx.getUserInfo({
            success: function (selfUser) {
              self.getUserDetail(selfUser)
            }
          })
        }
      }
    })

  },
  onDialog(){
    this.setData({
      dialog: !this.data.dialog
    })
  },
  getUserInfo(e){
    this.setData({
      dialog: false
    })
    this.getUserDetail(e.detail)
  },
  getUserDetail(info){
    Comfn.setStor('wx_self_info', info.userInfo);
    IndexApi.getIndex.call(this, {}, op => {
      this.setData({
        indexTable: op
      })
    })
  },
  onLoad: function(option) {

  },
})